package com.pc.admin.common;


import java.util.Arrays;
import java.util.HashMap;
import java.util.Map;
import java.util.stream.Collectors;

public enum MyResultCode {
    Success(200,"成功"),
    SuccessStock(202,"减库存成功"),
    PARAM_IS_BLANK(102,"参数为空"),
    PROCESS_FAULT(103,"下单失败，请稍后重试"),
    PROCESS_EMPTY(104,"下单失败，商品已卖光"),
    PROCESS_ERROR(500,"系统出现异常");
    private Integer code;

    private String message;

    private static Map<Integer,String> map;

    static {
        map = Arrays.stream(MyResultCode.values()).collect(Collectors.toMap(MyResultCode::getCode, MyResultCode::getMessage));
    }

    private MyResultCode(Integer code, String message) {
        this.code = code;
        this.message = message;
    }

    public Integer getCode() {
        return code;
    }

    public void setCode(Integer code) {
        this.code = code;
    }

    public String getMessage() {
        return message;
    }

    public void setMessage(String message) {
        this.message = message;
    }

    public String isMessage(Integer code){
        return map.get(code);
    }
}
